/**
 * @file    WebStorage.cpp
 * @brief   
 * @date    2005-03-15 15:55:23
 * @author  GengYong (gengyong@gmail.com)
 *
 */

#include <cassert>
#include "WebStorage.h"

using namespace xessage_private;

WebStorage::WebStorage(WebWindowImpl * app):m_appImpl(app), m_refCount(1)
{
	return;
}

WebStorage::~WebStorage()
{
	return;
}

HRESULT STDMETHODCALLTYPE WebStorage::QueryInterface(REFIID riid, LPVOID * ppvObject)
{
	if (ppvObject == NULL) return E_POINTER;

	if ((memcmp(&riid, &IID_IUnknown, sizeof(GUID)) == 0) || (memcmp(&riid, &IID_IStorage, sizeof(GUID)) == 0))
	{
		this->AddRef();
		*ppvObject = this;
	}
	else
	{
		*ppvObject = 0;
		return E_NOINTERFACE;
	}
	return S_OK;
}

ULONG STDMETHODCALLTYPE WebStorage::AddRef()
{
	return InterlockedIncrement(&m_refCount);
}

ULONG STDMETHODCALLTYPE WebStorage::Release()
{
	LONG result = InterlockedDecrement(&m_refCount);
	assert(result >= 0);
	if (result == 0)
	{
		delete this;
	}
	return (ULONG)(result);
}

HRESULT STDMETHODCALLTYPE WebStorage::CreateStream(const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::OpenStream(const WCHAR * pwcsName, void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::CreateStorage(const WCHAR *pwcsName, DWORD grfMode, DWORD reserved1, DWORD reserved2, IStorage **ppstg)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::OpenStorage(const WCHAR * pwcsName, IStorage * pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstg)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::CopyTo(DWORD ciidExclude, IID const *rgiidExclude, SNB snbExclude,IStorage *pstgDest)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::MoveElementTo(const OLECHAR *pwcsName,IStorage * pstgDest, const OLECHAR *pwcsNewName, DWORD grfFlags)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::Commit(DWORD grfCommitFlags)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::Revert()
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::EnumElements(DWORD reserved1, void * reserved2, DWORD reserved3, IEnumSTATSTG ** ppenum)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::DestroyElement(const OLECHAR *pwcsName)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::RenameElement(const WCHAR *pwcsOldName, const WCHAR *pwcsNewName)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::SetElementTimes(const WCHAR *pwcsName, FILETIME const *pctime, FILETIME const *patime, FILETIME const *pmtime)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::SetClass(REFCLSID clsid)
{
	return S_OK;
}

HRESULT STDMETHODCALLTYPE WebStorage::SetStateBits(DWORD grfStateBits, DWORD grfMask)
{
	return E_NOTIMPL;;
}

HRESULT STDMETHODCALLTYPE WebStorage::Stat(STATSTG * pstatstg, DWORD grfStatFlag)
{
	return E_NOTIMPL;;
}
